package com.qf.controller;

import com.qf.bo.RoleBO;
import com.qf.service.RoleService;
import com.qf.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @USER: Administrator
 * @DATE: 2025/9/6 下午9:07
 * @VERSION: 1.0.0
 */
@RestController
@RequestMapping("/role")
public class RoleController {

    @Autowired
    private RoleService roleService;

    /**
     * 查询所有角色信息
     * @return
     */
    @RequestMapping("/queryAll")
    public ResultVO queryAllRole() {
        return ResultVO.success(roleService.queryAllRole());
    }

    /**
     * 新增或修改角色信息
     * @param roleBO 角色信息
     * @return resultVO
     */
    @PostMapping("/saveOrUpdate")
    public ResultVO saveOrUpdate(@ModelAttribute RoleBO roleBO){
        return ResultVO.success(roleService.saveOrUpdate(roleBO));
    }

    /**
     * 删除角色信息
     * @param id 角色id
     * @return resultVO
     */
    @DeleteMapping("/delete/{id}")
    public ResultVO deleteRole(@PathVariable Long id){
        return ResultVO.success(roleService.deleteRole(id));
    }
}
